﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Security.Cryptography;
using System.Collections.Specialized;
using System.IO;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Net;
using Cosmetic;
using Cosmetic.DataEntity;
using Cosmetic.Logic;
namespace WebApp.Shopping
{
    public partial class shangfu : System.Web.UI.Page
    {
        private OrderManager m_orderManger = new OrderManager();
        private ProductManager m_ProductManager = new ProductManager();
        protected void Page_Load(object sender, EventArgs e)
        {

            if(!IsPostBack )
            {
            Order theOrderes = m_orderManger.GetOrderByIds1(Request.QueryString["TradeNo"]);
            //OrderDetail theorder1 = m_orderManger.GetOrderByIdes(theOrderes.OrderId);
            //ProductInfo thepro = m_ProductManager.GetProductByIdes1(theorder1.ProductId);
            //业务参数赋值；
            //string gateway = "https://www.alipay.com/cooperate/gateway.do?";	//支付接口

            //业务参数赋值；
            //string gateway = "https://www.alipay.com/cooperate/gateway.do?";	//支付接口
            string gateway = "http://218.242.161.172:9080/gateway/paymentorder?";
            string key = "yw9q84ywu2903wjr";                    //安全校验码
            string mer_id = "1234";                                //商户ID
            string _input_charset = "UTF-8";                                    //编码类型
            string order_date = DateTime.Now.ToString("yyyyMMdd");
            string order_time = DateTime.Now.ToString("HHmmss");
            string out_trade_no = Request.QueryString["TradeNo"];                       //客户网站订单号，（现取系统时间，可改成网站自己的变量）
            string item_name = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Second.ToString();                         //商品名称
            string body = "空";                                  //商品描述,没有用到 可去掉
            int  order_amount =  Convert .ToInt32(theOrderes.Price + theOrderes.DeliveryPrice)*100;                                    //商品价格(总价)

            //服务器通知url（Alipay_Notify.asp文件所在路经）
            string mer_url = "http://www.jj-9.com/Shopping/WebPayReturn.aspx";  // 此处可以用localhost:1234 这种URL 因为alipay是js跳转
            //服务器返回url（return_Alipay_Notify.asp文件所在路经）
            string return_url = "http://www.jj-9.com/Shopping/WebPayReturn.aspx";
            //相关参数名称具体含义，可以在支付宝接口服务文档中查询到，
            //以上两个文件，通知正常都可以在notify data目录找到通知过来的日志
            string aliay_url = WebPay.NewUrl(
            mer_id,
            out_trade_no,
            order_date,
            order_time,
            order_amount,
                //item_count ,
            item_name,
             mer_url,
            return_url,
            "",//mer_order_param
            key,
            _input_charset,
            gateway
            );
            HttpContext.Current.Response.Redirect(aliay_url);
 
            }
           
        }
    }

}
        